const app = getApp()
Page({
  data: {
    list: app.globalData.shopCar,
    sum: 0,
    duole: ''
  },
  onShow() {
    this.getData()
  },
  getData() {
    this.setData({
      list: app.globalData.shopCar
    })
  },
  //改变
  gaibian() {
    this.getData()
    let sum = 0
    this.data.list.forEach(e => {
      sum += e.price * e.numb
    })
    this.setData({
      duole: this.data.list.length,
      sum
    })
    console.log("来瞧瞧数据", app.globalData.shopCar)
  },
  //取消
  quexiao(e) {
    if (e.detail.s) {
      this.setData({
        sum: this.data.sum + e.detail.sum,
        duole: this.data.duole + 1
      })
    } else {
      this.setData({
        sum: this.data.sum - e.detail.sum,
        duole: this.data.duole - 1
      })
    }
  }
})